package net.lijingye.education.vo;

import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.SerializerFeature;
import net.lijingye.education.entity.Topic;
import net.lijingye.education.util.CommonUtil;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by LijingYe on 2016/3/26.
 */
public class TopicVO {
    @JSONField(name = "id", ordinal = 0, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String id;
    @JSONField(name = "type", ordinal = 1, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String type;
    @JSONField(name = "lessonId", ordinal = 2, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String lessonId;
    @JSONField(name = "lessonName", ordinal = 3, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String lessonName;
    @JSONField(name = "title", ordinal = 4, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String title;
    @JSONField(name = "isSolved", ordinal = 5, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private Boolean isSolved;
    @JSONField(name = "time", ordinal = 6, serialzeFeatures = SerializerFeature.WriteMapNullValue, format = "yyyy/MM/dd HH:mm")
    private Date time;
    @JSONField(name = "authorId", ordinal = 7, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String authorId;
    @JSONField(name = "authorName", ordinal = 8, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String authorName;
    @JSONField(name = "authorFaceIcon", ordinal = 9, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String authorFaceIcon;
    @JSONField(name = "content", ordinal = 10, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String content;
    @JSONField(name = "kickTime", ordinal = 11, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private Integer kickTime;
    @JSONField(name = "replyCount", ordinal = 12, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private Integer replyCount;
    @JSONField(name = "file", ordinal = 13, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private List<String> file;

    public TopicVO(Topic topic) {
        this.id = String.valueOf(topic.getId());
        this.type = CommonUtil.getTopicTypeText(topic);
        this.lessonId = topic.getLesson().getId();
        this.lessonName = topic.getLesson().getCourse().getName();
        this.title = topic.getTitle();
        this.isSolved = CommonUtil.getTopicIsSolvedBoolean(topic);
        this.time = topic.getTime();
        this.authorId = topic.getAuthor().getId();
        this.authorName = CommonUtil.getUserDisplayName(topic.getAuthor());
        this.authorFaceIcon = topic.getAuthor().getFaceIcon();
        this.content = topic.getContent();
        this.kickTime = topic.getKickTime();
        this.replyCount = topic.getTopicReplyList().size();
        this.file = new ArrayList<>();
        topic.getTopicFileList().forEach(topicFile -> {
            file.add(topicFile.getPath());
        });
    }

    public TopicVO(String id, String type, String lessonId, String lessonName, String title, Boolean isSolved, Date time, String authorId, String authorName, String authorFaceIcon, String content, Integer kickTime, Integer replyCount, List<String> file) {
        this.id = id;
        this.type = type;
        this.lessonId = lessonId;
        this.lessonName = lessonName;
        this.title = title;
        this.isSolved = isSolved;
        this.time = time;
        this.authorId = authorId;
        this.authorName = authorName;
        this.authorFaceIcon = authorFaceIcon;
        this.content = content;
        this.kickTime = kickTime;
        this.replyCount = replyCount;
        this.file = file;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getLessonId() {
        return lessonId;
    }

    public void setLessonId(String lessonId) {
        this.lessonId = lessonId;
    }

    public String getLessonName() {
        return lessonName;
    }

    public void setLessonName(String lessonName) {
        this.lessonName = lessonName;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Boolean getSolved() {
        return isSolved;
    }

    public void setSolved(Boolean solved) {
        isSolved = solved;
    }

    public Date getTime() {
        return time;
    }

    public void setTime(Date time) {
        this.time = time;
    }

    public String getAuthorId() {
        return authorId;
    }

    public void setAuthorId(String authorId) {
        this.authorId = authorId;
    }

    public String getAuthorName() {
        return authorName;
    }

    public void setAuthorName(String authorName) {
        this.authorName = authorName;
    }

    public String getAuthorFaceIcon() {
        return authorFaceIcon;
    }

    public void setAuthorFaceIcon(String authorFaceIcon) {
        this.authorFaceIcon = authorFaceIcon;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Integer getKickTime() {
        return kickTime;
    }

    public void setKickTime(Integer kickTime) {
        this.kickTime = kickTime;
    }

    public Integer getReplyCount() {
        return replyCount;
    }

    public void setReplyCount(Integer replyCount) {
        this.replyCount = replyCount;
    }

    public List<String> getFile() {
        return file;
    }

    public void setFile(List<String> file) {
        this.file = file;
    }

    @Override
    public String toString() {
        return "TopicVO{" +
                "id='" + id + '\'' +
                ", type='" + type + '\'' +
                ", lessonId='" + lessonId + '\'' +
                ", lessonName='" + lessonName + '\'' +
                ", title='" + title + '\'' +
                ", isSolved=" + isSolved +
                ", time=" + time +
                ", authorId='" + authorId + '\'' +
                ", authorName='" + authorName + '\'' +
                ", authorFaceIcon='" + authorFaceIcon + '\'' +
                ", content='" + content + '\'' +
                ", kickTime=" + kickTime +
                ", replyCount=" + replyCount +
                ", file=" + file +
                '}';
    }
}
